/**
 * “自动分配”管理页面
 * - 使用自定义封装组件，简化代码，统一管理。
 * - 2025-09-10 17:09:54 tzj
 * */

import withBasePage from "../../components/BaseComponent/withBasePage";
import {zdfpApi, zdfpApi as selectPage} from "../../services/basic";
import EditItem from "./addOrEdit"
import React from "react";

// 要显示的form表单
const formItemList =
    [
        // "fuzzy",
        "companies",
        {
            name:"person",
            label:"员工姓名",
            keyword:"yggh"
        },
        "project",
        "stateFlag2",
    ];

// 显示的按钮
const buttons = ["query", "add", "export", "edit", "delete"];
// 表格列信息
const columns = [
    {
        title: '员工姓名',
        dataIndex: 'xm',
    },
    {
        title: '意向项目',
        dataIndex: 'yxxmmc',
    },
    {
        title: "公司名称",
        dataIndex: "yymc",
    },
    {
        title: "比例",
        dataIndex: "bl",
    },
    {
        title: "状态",
        dataIndex: "ztbz",
        render: (_, recored) => ["无效", "有效"][~~recored["ztbz"]]
    },
    {
        title: "每日留资数",
        dataIndex: "mrlzs",
    },
]

// 加工数据
const dataProcess = res => {
    console.log("----")
    console.log(res)
    return res
}

// 实际执行还是在class里，而非视为function
const modalRef = React.createRef()

// 打开弹窗
const setHandler = (handler, record) => {
    modalRef.current.showModal(handler, record)
    console.log(handler, record)
}

export default withBasePage({
    state: {
        formItemList,
        buttons,
        // columns,
        filename: "自动分配",
        // queryAll: true,
        // sumRow: true,
        // resNormal: true,
        // rowKey: "jhid",
    },
    columns,
    queryApi: selectPage.selectPage,
    dataProcess,
    setHandler,
    deleteApi: zdfpApi.deleteFp,
    // hasLzModal: true,
    onRowDoubleClick(record) {
        setHandler("view", record)
    },
    extraContentAfterTable: (hoc) => <EditItem editItemDone={() => hoc.queryDataList()} ref={modalRef}></EditItem>,
})(() => null);
